package com.skywolf.chem.usercenterapi;


import com.skywolf.chem.common.sysconfig.pojo.vo.PageVO;
import com.skywolf.chem.common.sysconfig.response.RespData;
import com.skywolf.chem.manager.entity.OpinionParam;
import com.skywolf.chem.usercenterapi.entity.SuggestInfo;
import com.skywolf.chem.usercenterapi.service.ISuggestInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 系统建议信息采集表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-09
 */
@RestController
@RequestMapping("/ct/usercenter/suggest-info")
public class SuggestInfoController {

    @Autowired
    ISuggestInfoService suggestInfoService;

    @ApiOperation(value = "用户反馈",notes = "用户反馈")
    @RequestMapping(value = "/userSuggest",method = {RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespData<String> userSuggest(@RequestBody @Validated SuggestInfo suggestInfo, HttpServletRequest request) {
        String uid = request.getHeader("user_id");
        suggestInfo.setCusUid(Long.valueOf(uid));
        suggestInfoService.save(suggestInfo);
        return RespData.success("success");
    }

    @ApiOperation(value = "我的反馈列表",notes = "我的反馈列表")
    @RequestMapping(value = "/mySuggestList",method = {RequestMethod.POST},produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public RespData<SuggestInfo> mySuggestList(@RequestBody @Validated OpinionParam queryParam, HttpServletRequest request) {
        String uid = request.getHeader("user_id");
        queryParam.setUid(Long.valueOf(uid));
        PageVO<SuggestInfo> page = suggestInfoService.pageSuggestInfoList(queryParam);
        return RespData.success(page);
    }
}
